<div id="login-dialog">
    <form id="login-form">
        <div class="input-group">
            <!--<label for="login-name" class="input-group-addon">账号</label>-->
            <input type="email" name="login_name" id="login-name" class="form-control" minlength="3" maxlength="30" required="required" placeholder="邮箱账号"/>
        </div>
        <div class="input-group">
            <!--<label for="login-password" class="input-group-addon">密码</label>-->
            <input type="password" name="login_password" id="login-password" class="form-control" maxlength="30" required="required" placeholder="密码"/>
        </div>
        <div class="left-right-side" style="margin-top:20px; font-size:12px; color:#828282">
            <span class="left-side"><input type="checkbox" checked="checked" name="login-auto" id="login-auto" style="margin: 0 4px 0 0; vertical-align: -2px;"/><label for="login-auto" style="cursor: pointer"> 下次自动登陆</label></span>
            <span class="right-side"><a class="forgetPassword" href="<?php echo base_url('home/resetpwd') ?>">忘记密码？</a></span>
        </div>
        <div class="input-group">
            <input type="submit" class="btn btn-success form-control" value="登 录" style="margin-top:10px;"/>
        </div>
        <div class="left-right-side">
            <span class="left-side" style="color:#E75632; line-height:30px;">快速登陆：</span>
            <a href="<?php echo $Weibo_URL; ?>" id="WB-login" title="新浪微博登陆">微博登陆</a>
            <span class="right-side"><a class="signUp" href="javascript:" title="立即注册">立即注册</a></span>
        </div>
        <div class="clearfix"></div>
    </form>
</div>
<script>
    $(function () {
        $.AutoComplete('#login-name');

        $("#login-form").validate({
            submitHandler: function (form) {
                $.ajax({
                    url: '<?php echo base_url('api/login');?>',
                    type: 'post',
                    data: $(form).serialize(),
                    beforeSend: function () {
                        showProgressNoty();
                    },
                    complete: function () {
                        closeProgressNoty();
                    },
                    success: function (jsonrsp) {
                        try {
                            var rsp = $.parseJSON(jsonrsp);
                            noty({type: rsp.type, text: rsp.message, callback: {
                                afterClose: function () {
                                    switch (rsp.type) {
                                        case 'success':
                                            //location.href=base_url('home/changeschool/'+rsp.data.schoolunicode);
                                            location.reload();
                                            break;
                                        case 'alert':
                                            window.location.href=base_url('home/binduser');
                                            break;
                                        default:
                                            break;
                                    }
                                }
                            }});
                        } catch (ex) {
                            noty({type: 'error', text: '发生内部错误，请联系管理员'});
                            throw ex;
                        }
                    }
                });
            }
        });
    });
</script>